home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cvs / sprite / RCS / build_entry.c,v < prev    next >
Encoding:
Text File  |  1991-07-29  |  3.0 KB  |  132 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.07.29.11.53.37;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.07.11.13.03.10;  author jhh;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @no /dev/tty in sprite
  27. @
  28. text
  29. @#ifndef lint
  30. static char rcsid[] = "$Id: build_entry.c,v 1.1 91/07/11 13:03:10 jhh Exp Locker: jhh $";
  31. #endif !lint
  32.  
  33. /*
  34.  *    Copyright (c) 1989, Brian Berliner
  35.  *
  36.  *    You may distribute under the terms of the GNU General Public License
  37.  *    as specified in the README file that comes with the CVS 1.0 kit.
  38.  *
  39.  * Build Entry
  40.  *
  41.  *    Builds an entry for a new file and sets up "CVS.adm/file",[pt] by
  42.  *    interrogating the user.
  43.  *
  44.  *    Returns non-zero on error.
  45.  */
  46.  
  47. #include <sys/param.h>
  48. #include "cvs.h"
  49.  
  50. Build_Entry(message)
  51.     char *message;
  52. {
  53.     char fname[MAXPATHLEN];
  54.     char line[MAXLINELEN];
  55.     FILE *fp, *fptty;
  56.  
  57.     /*
  58.      * There may be an old file with the same name in the Attic!
  59.      * This is, perhaps, an awkward place to check for this, but
  60.      * other places are equally awkward.
  61.      */
  62.     (void) sprintf(fname, "%s/%s/%s%s", Repository, CVSATTIC, User, RCSEXT);
  63.     if (isreadable(fname)) {
  64.     warn(0, "there is an old file %s already in %s/%s", User,
  65.          Repository, CVSATTIC);
  66.     return (1);
  67.     }
  68.     /*
  69.      * The options for the "add" command are store in the file CVS.adm/User,p
  70.      */
  71.     (void) sprintf(fname, "%s/%s%s", CVSADM, User, CVSEXT_OPT);
  72.     fp = open_file(fname, "w+");
  73.     if (fprintf(fp, "%s\n", Options) == EOF)
  74.     error(1, "cannot write %s", fname);
  75.     (void) fclose(fp);
  76.     /*
  77.      * And the requested log is read directly from the user and stored
  78.      * in the file User,t.  If the "message" argument is set, then the
  79.      * user specified the -m option to add, and it is not necessary to
  80.      * query him from the terminal.
  81.      */
  82.     (void) sprintf(fname, "%s/%s%s", CVSADM, User, CVSEXT_LOG);
  83.     fp = open_file(fname, "w+");
  84.     if (message[0] == '\0') {
  85.     printf("RCS file: %s\n", Rcs);
  86.     printf("enter description, terminated with ^D or '.':\n");
  87.     printf("NOTE: This is NOT the log message!\n");
  88. #ifdef sprite
  89.     fptty = open_file(getenv("TTY"), "r");
  90. #else
  91.     fptty = open_file("/dev/tty", "r");
  92. #endif
  93.     for (;;) {
  94.         printf(">> ");
  95.         (void) fflush(stdout);
  96.         if (fgets(line, sizeof(line), fptty) == NULL ||
  97.         (line[0] == '.' && line[1] == '\n'))
  98.         break;
  99.         if (fputs(line, fp) == EOF)
  100.         error(1, "cannot write to %s", fname);
  101.     }
  102.     printf("done\n");
  103.     (void) fclose(fptty);
  104.     } else {
  105.     if (fputs(message, fp) == EOF)
  106.         error(1, "cannot write to %s", fname);
  107.     }
  108.     (void) fclose(fp);
  109.     /*
  110.      * Create the entry now, since this allows the user to interrupt
  111.      * us above without needing to clean anything up (well, we could
  112.      * clean up the ,p and ,t files, but who cares).
  113.      */
  114.     (void) sprintf(line, "Initial %s", User);
  115.     Register(User, "0", line);
  116.     return (0);
  117. }
  118. @
  119.  
  120.  
  121. 1.1
  122. log
  123. @Initial revision
  124. @
  125. text
  126. @d2 1
  127. a2 1
  128. static char rcsid[] = "$Id: build_entry.c,v 1.9 89/11/19 23:19:45 berliner Exp $";
  129. d60 3
  130. d64 1
  131. @
  132.